<script language="javascript">
$(function(){
	$('form').form({ 
		success:function(data){
			var data = runJson(data);
			if(data.status == 0){
				alertText(data.info, 'error');
			}else{
				alertText(data.info, 'success', 'back');
			}
		}   
	});
	$('#attr_group_id').change(function(){
		$.getJSON('{:U("Attribute/selectOption")}&id='+$(this).val(),function(data){
			$("#attr1_id,#attr2_id").html(data.info);
		});
	});
});
</script>
<div class="box">
	<div class="easyui-panel" title="<eq name='ACTION_NAME' value='edit'>编辑<else />添加</eq>产品分类">
        <form action="<eq name='ACTION_NAME' value='edit'>{:U('Category/update')}<else />{:U('Category/insert')}</eq>&ajax=true" method="post">
    	<table width="100%" border="0" cellspacing="0" cellpadding="0" class="table">
          <tr>
            <td class="label">产品分类名称：</td>
            <td>
            <input type="text" value="{$vo.name}" id="name" name="name" style="width:200px;" class="easyui-validatebox input" required="true" validType="length[2,20]" />
            </td>
          </tr>
          <tr>
            <td class="label">所属上级分类：</td>
            <td>
            <select name="parent_id" required="true" validType="length[1,20]">
            <option value="0">顶级分类</option>
            <volist name="catelist" id="cate">
            <option value="{$cate.id}" <if condition="$vo['parent_id'] eq $cate['id']">selected</if>>{$cate.repeat}{$cate.name}</option>
            </volist>
            </select>
            </td>
          </tr>
          <tr>
            <td class="label">关联的属性组：</td>
            <td>
            <select name="attr_group_id" id="attr_group_id">
            <option value="0">选择属性组</option>
            <volist name="attribute" id="attr">
            <option value="{$key}" <if condition="$vo['attr_group_id'] eq $key">selected</if>>{$attr}</option>
            </volist>
            </select>
            <p class="notice">请选择产品所需要关联的属性组并指写绑定的属性。</p>
            </td>
          </tr>
          <tr style="display:none;">
            <td class="label">绑定属性一(颜色)：</td>
            <td>
            <select id="attr1_id" name="attr1">
            <option value="0">请先选择属性组</option>
            </select>
            <p class="notice">该属性一般是关联产品跟颜色相关的属性。</p>
            </td>
          </tr>
          <tr style="display:none;">
            <td class="label">绑定属性二(尺码)：</td>
            <td>
            <select id="attr2_id" name="attr2">
            <option value="0">请先选择属性组</option>
            </select>
            <p class="notice">该属性一般是关联产品跟尺码相关的属性。</p>
            </td>
          </tr>
          <tr>
            <td class="label">状态：</td>
            <td>
            <select name="status">
            <option value="1" <eq name="vo['status']" value="1">selected</eq>>启用</option>
            <option value="0" <eq name="vo['status']" value="0">selected</eq>>禁用</option>
            </select>
            </td>
          </tr>
          <tr>
            <td class="label">排序：</td>
            <td>
            <input type="text" class="input" name="sort" id="sort" value="{$vo.sort}" style="width:100px;" />
            </td>
          </tr>
          <tr>
            <td class="label">备注：</td>
            <td>
            <textarea class="input" name="remark" id="remark" style="width:300px; height:100px;">{$vo.remark}</textarea>
            </td>
          </tr>
          <tr>
            <td class="label">&nbsp;</td>
            <td>
            <eq name='ACTION_NAME' value='edit'><input type="hidden" name="id" value="{$vo.id}" /></eq>
            <input name="action" type="hidden" value="{$Think.const.ACTION_NAME}" />
            <input align="absmiddle" class="button" type="submit" value="保存" id="submits" onclick="return $('form').form('validate')" />
            </td>
          </tr>
        </table>
        </form>
    </div>
</div>